using System;
using System.Diagnostics;
using System.IO;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.ServiceRuntime;

namespace SBPweb.PlAzureNet.Cloud.Services
{

    public class LocalStorageTraceListener : XmlWriterTraceListener
    {

        public LocalStorageTraceListener()
            : base(Path.Combine(LocalStorageTraceListener.GetLogDirectory().Path, "SBPweb.PlAzureNet.Cloud.Services.svclog"))
        {
        }

        public static DirectoryConfiguration GetLogDirectory()
        {
            DirectoryConfiguration directory = new DirectoryConfiguration();
            directory.Container = "wad-tracefiles";
            directory.DirectoryQuotaInMB = 10;
            directory.Path = RoleEnvironment.GetLocalResource("SBPweb.PlAzureNet.Cloud.Services.svclog").RootPath;
            return directory;
        }

    }

}